﻿/*
    Copyright 2011 Andrew Sydney
 
    This file is part of Syd.ScheduleControls.

    Syd.ScheduleControls is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Syd.ScheduleControls is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Syd.ScheduleControls.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Drawing;
using System.Windows.Forms;

namespace CMS_GYM.Interface
{
	/// <summary>
	/// Dialog for editing an appointment.
	/// </summary>
	public partial class frmSuaLichKhachHangVangLai : Form
	{

        /// <summary>
        /// Initializes a new instance of the <see cref="frmSuaLichSanCauLong"/> class.
        /// </summary>
        public frmSuaLichKhachHangVangLai()
		{
			InitializeComponent();
           
		}
        public int LichChiTietId { get; set; }
        public int NgayTrongTuanId { get; set; }
        public int LichId { get; set; }
        public string MoTa = string.Empty;
        /// <summary>
        /// Gets or sets the appointment title.
        /// </summary>
        /// <value>
        /// The appointment title.
        /// </value>
		public string AppointmentTitle {get{return this.txtTitle.Text;}set{this.txtTitle.Text=value;}}
        /// <summary>
        /// Gets or sets the appointment date end.
        /// </summary>
        /// <value>
        /// The appointment date end.
        /// </value>
		public DateTime AppointmentDateEnd {get{return this.dtpDateEnd.Value;}set{this.dtpDateEnd.Value=value;}}
        /// <summary>
        /// Gets or sets the appointment date start.
        /// </summary>
        /// <value>
        /// The appointment date start.
        /// </value>
		public DateTime AppointmentDateStart {get{return this.dtpDateStart.Value;}set{this.dtpDateStart.Value=value;}}

        /// <summary>
        /// Save button clicked.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		void BtnSaveClick(object sender, EventArgs e)
		{
			if (string.IsNullOrEmpty(txtTitle.Text))
			{
				lblValidation.Text="Kiểm tra họ tên khách hàng.";
			}
			else if (dtpDateStart.Value >= dtpDateEnd.Value)
			{
				lblValidation.Text="Giờ kết thúc phải lớn hơn giờ bắt đầu.";
			}
			else
			{
                if (rbtKhachHangVangLaiChuaThu.Checked)
                {
                    AppointmentTitle = "KH vãng lai (chưa thu)";
                    MoTa = " (chưa thu)";
                }
                else if (rbtKhachHangVangLaiDaThu.Checked)
                {
                    AppointmentTitle = "KH vãng lai (đã thu)";
                    MoTa = " (đã thu)";
                }
				this.DialogResult = DialogResult.OK;
				this.Close();
			}
		}

        /// <summary>
        /// Cancel button clicked.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		void BtnCancelClick(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
			this.Close();
		}

        /// <summary>
        /// Date picker value changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		void DtpDateStartValueChanged(object sender, EventArgs e)
		{
			if (dtpDateEnd.Value <= dtpDateStart.Value)
			{
				dtpDateEnd.Value = dtpDateStart.Value.AddMinutes(15);
			}
		}

        private void btnDelete_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Abort;
            this.Close();
        }

        private void btnTinhTien_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Yes;
            //this.AppointmentTitle = "KH vãng lai";
            MoTa = " (đã thu)";
            this.Close();
        }

        private void frmSuaLichKhachHangVangLai_Load(object sender, EventArgs e)
        {
            if (AppointmentTitle == "KH vãng lai (chưa thu)")
            {
                rbtKhachHangVangLaiChuaThu.Checked = true;
                //rbtKhachHangVangLaiDaThu.Checked = false;
            }
            else if (AppointmentTitle == "KH vãng lai (đã thu)")
            {
                rbtKhachHangVangLaiDaThu.Checked = true;
                //rbtKhachHangVangLaiChuaThu.Checked = false;
            }
            MoTa = string.Empty;
        }
	}
}
